package org.example;

public class Test6 {
    //leetcode 383 赎金信 https://leetcode.cn/problems/ransom-note/description/
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] hash1 = new int[26];
        for (char c : magazine.toCharArray()) {
            hash1[c - 'a']++;
        }
        for (char c : ransomNote.toCharArray()) {
            int in = c - 'a';
            hash1[in]--;
            if (hash1[in] < 0) return false;
        }
        return true;
    }
}
